import service from '@/utils/request'

const BASE_URL = 'api-course'

// 获取班级列表
export function courseList(data) {
    return service({
        url: `${BASE_URL}/courses`,
        method: 'get',
        params: data
    })
}

// 课程分类统计
export function courseReport() {
    return service({
        url: `${BASE_URL}/course/report`,
        method: 'get'
    })
}

// 获取详情
export function courseDetail(courseId) {
    return service({
        url: `${BASE_URL}/course/${courseId}`,
        method: 'get',
    })
}

// 新增班级
export function addcourse(data) {
    return service({
        url: `${BASE_URL}/course`,
        method: 'post',
        data
    })
}

// 编辑班级
export function editcourse(data) {
    return service({
        url: `${BASE_URL}/course`,
        method: 'put',
        data
    })
}

// 删除班级
export function deletecourse(courseId) {
    return service({
        url: `${BASE_URL}/course/${courseId}`,
        method: 'delete'
    })
}

// /category/tree


export function getCategory() {
    return service({
        url: `${BASE_URL}/category/tree`,
        method: 'get'
    })
}

//启用/停用
export function enableCourse(courseId) {
    return service({
        url: `${BASE_URL}/course/enable/${courseId}`,
        method: 'put',
    })
}

// 审核
export function auditCourse(data) {
    return service({
        url: `${BASE_URL}/course/audit`,
        method: 'put',
        data
    })
}

//添加申请授权
export function addCourseTeaching(data) {
    return service({
        url: `${BASE_URL}/course/teaching`,
        method: 'post',
        data
    })
}

// 获取班级列表
export function courseTeachingList(courseId) {
    return service({
        url: `${BASE_URL}/course/${courseId}/teaching`,
        method: 'get'
    })
}

//同意授课--就是加入课程库
export function agreedTeach(courseId) {
    return service({
        url: `${BASE_URL}/course/${courseId}/teaching`,
        method: 'put'
    })
}

//批量加入课程库
export function agreeCourseBatchTeaching(data) {
    return service({
        url: `${BASE_URL}/course/batch/teaching`,
        method: 'post',
        data
    })
}

//课程库列表
export function courseLibraryList(data) {
    return service({
        url: `${BASE_URL}/courses/library`,
        method: 'get',
        params: data
    })
}


//课程库移除
export function removeCourseLibrary(libraryId) {
    return service({
        url: `${BASE_URL}/course/library/${libraryId}`,
        method: 'delete'

    })
}

//获取审批原因
export function getAuditMessage(courseId) {
    return service({
        url: `${BASE_URL}/course/${courseId}/audit-message`,
        method: 'get'
    })
}

//申请授课取消
export function cancelCourseTeaching(courseId, teachingId) {
    return service({
        url: `${BASE_URL}/course/${courseId}/teaching/${teachingId}`,
        method: 'delete'
    })
}

//简单课程
export function listSimpleCourse(areaId) {
    return service({
        url: `${BASE_URL}/courses/simple/${areaId}`,
        method: 'get'
    })
}
